@extends('shop::layouts.master')
@section('title')
    检测机构列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            {{csrf_field()}}
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="name" placeholder="检测机构名称" value="{{$data['name']}}"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="phone" placeholder="联系电话" value="{{$data['phone']}}"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="type">
                                    <option value="">类型</option>
                                    @foreach($list['type'] as $k => $v)
                                    <option value="{{$k}}" @if($data['type']==$k) selected @endif>{{$v}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    {{--<div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加','{{route('shop_checkpoint_create')}}')">
                            <i class="layui-icon"></i>添加
                        </button>
                    </div>--}}
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>检测机构名称</th>
                                <th>类型</th>
                                <th>联系方式</th>
                                <th>地址</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            @foreach($list['data'] as $key=>$value)
                                <tr>
                                    <td>{{$value['id']}}</td>
                                    <td>{{$value['name']}}</td>
                                    <td>{{$value['type']['title']}}</td>
                                    <td>{{$value['phone']}}</td>
                                    <td>{{$value['address']}}</td>
                                    <td>{{$value['created_at']}}</td>
                                    <td class="td-manage">
                                        <a title="查看" class="layui-btn layui-btn-primary" onclick="xadmin.open('查看','order-view.html')" href="javascript:;">
                                            查看
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                            @if(empty($list['data']))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$list['page_link']}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['laydate', 'form'],
            function () {
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#start' //指定元素
                });

                //执行一个laydate实例
                laydate.render({
                    elem: '#end' //指定元素
                });
            }
        );

        /*删除*/
        function soft_del(obj, url, id) {
            layer.confirm('确认要删除吗？', function (index) {

                $.ajax({
                    type: "delete",
                    url: url,
                    data: {'id': id, '_token': '{{csrf_token()}}'},
                    dataType: "json",
                    success: function (res) {
                        if (res > 0) {
                            //发异步删除数据
                            $(obj).parents("tr").remove();
                            layer.msg('已删除!', {icon: 1, time: 1000});
                            //location.reload();
                        } else {
                            layer.msg('已删失败!', {icon: 1, time: 1000});
                        }
                    }, error: function () {
                        alert("发生错误：");
                    }
                });

            });
        }

    </script>
@endsection




